package com.bridgeQQ.client.log
{
	import com.bridgeQQ.client.model.BridgeModel;
	import com.bridgeQQ.client.vo.User;
	
	import flash.filesystem.File;
	import flash.filesystem.FileMode;
	import flash.filesystem.FileStream;

	public class LogOutput
	{		
		private var fs:FileStream;
		
		private var file:File;
		
		public function LogOutput()
		{
		}
		
		public function log(message:String):void
		{
			var user:User = BridgeModel.instance.user;
			if(user == null)
			{
				return;
			}
			trace(message);
			try
			{
				if(file == null)
				{
					file = new File(File.userDirectory.url + "/bridgeqq/log_" + user.email + ".txt");
					fs = new FileStream();
				}
				fs.openAsync(file, FileMode.APPEND);
				fs.writeUTF(message + "\n");
				fs.close();
			}
			catch(e:Error)
			{
				
			}
			
		}
	}
}